#include "Slice.h"
#include "IVisitor.h"

Slice::Slice(const exprTypePtr& lower, const exprTypePtr& upper, const exprTypePtr& step, int nodeId):
    sliceType(nodeId),
    _lower(lower),
    _upper(upper),
    _step(step)
{
}
    
Slice::~Slice()
{
    
}
    
QString Slice::type() const
{
    return "Slice";
}
    

exprTypePtr Slice::lower()
{
    return _lower;
}

void Slice::setLower(const exprTypePtr& lower)
{
    _lower = lower;
}

exprTypePtr Slice::upper()
{
    return _upper;
}

void Slice::setUpper(const exprTypePtr& upper)
{
    _upper = upper;
}

exprTypePtr Slice::step()
{
    return _step;
}

void Slice::setStep(const exprTypePtr& step)
{
    _step = step;
}

    
QString Slice::toString() const
{
    return QString("Slice[lower=%1, upper=%2, step=%3]").
                arg(_lower ? _lower->toString():"").
                arg(_upper ? _upper->toString():"").
                arg(_step ? _step->toString():"");
}
    
void Slice::accept(IVisitor* visitor, const SimpleNodePtr& node)
{
    visitor->visitSlice(node.dynamicCast<Slice>());
}
    
void Slice::traverse(IVisitor* visitor)
{
    if (_lower != NULL)
        _lower->accept(visitor, _lower);
    if (_upper != NULL)
        _upper->accept(visitor, _upper);
    if (_step != NULL)
        _step->accept(visitor, _step);
}